<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveRecord::DynamicFinderMatch</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveRecord::DynamicFinderMatch</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/rails/activerecord/lib/active_record/dynamic_finder_match_rb.html">
                vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001664">bang?</a>&nbsp;&nbsp;
      <a href="#M001662">finder?</a>&nbsp;&nbsp;
      <a href="#M001663">instantiator?</a>&nbsp;&nbsp;
      <a href="#M001660">match</a>&nbsp;&nbsp;
      <a href="#M001661">new</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">attribute_names</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">finder</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">instantiator</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M001660" class="method-detail">
        <a name="M001660"></a>

        <div class="method-heading">
          <a href="#M001660" class="method-signature">
          <span class="method-name">match</span><span class="method-args">(method)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001660-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001660-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb, line 3</span>
3:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">method</span>)
4:       <span class="ruby-identifier">df_match</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">method</span>)
5:       <span class="ruby-identifier">df_match</span>.<span class="ruby-identifier">finder</span> <span class="ruby-value">? </span><span class="ruby-identifier">df_match</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
6:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001661" class="method-detail">
        <a name="M001661"></a>

        <div class="method-heading">
          <a href="#M001661" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(method)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001661-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001661-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb, line 8</span>
 8:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">method</span>)
 9:       <span class="ruby-ivar">@finder</span> = <span class="ruby-identifier">:first</span>
10:       <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>
11:       <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/</span>
12:         <span class="ruby-ivar">@finder</span> = <span class="ruby-identifier">:last</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$1</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'last_by'</span>
13:         <span class="ruby-ivar">@finder</span> = <span class="ruby-identifier">:all</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$1</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'all_by'</span>
14:         <span class="ruby-identifier">names</span> = <span class="ruby-identifier">$2</span>
15:       <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^find_by_([_a-zA-Z]\w*)\!$/</span>
16:         <span class="ruby-ivar">@bang</span> = <span class="ruby-keyword kw">true</span>
17:         <span class="ruby-identifier">names</span> = <span class="ruby-identifier">$1</span>
18:       <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/</span>
19:         <span class="ruby-ivar">@instantiator</span> = <span class="ruby-identifier">$1</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'initialize'</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">:new</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:create</span>
20:         <span class="ruby-identifier">names</span> = <span class="ruby-identifier">$2</span>
21:       <span class="ruby-keyword kw">else</span>
22:         <span class="ruby-ivar">@finder</span> = <span class="ruby-keyword kw">nil</span>
23:       <span class="ruby-keyword kw">end</span>
24:       <span class="ruby-ivar">@attribute_names</span> = <span class="ruby-identifier">names</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'_and_'</span>)
25:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001664" class="method-detail">
        <a name="M001664"></a>

        <div class="method-heading">
          <a href="#M001664" class="method-signature">
          <span class="method-name">bang?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001664-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001664-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb, line 37</span>
37:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bang?</span>
38:       <span class="ruby-ivar">@bang</span>
39:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001662" class="method-detail">
        <a name="M001662"></a>

        <div class="method-heading">
          <a href="#M001662" class="method-signature">
          <span class="method-name">finder?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001662-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001662-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb, line 29</span>
29:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finder?</span>
30:       <span class="ruby-operator">!</span><span class="ruby-ivar">@finder</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@instantiator</span>.<span class="ruby-identifier">nil?</span>
31:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001663" class="method-detail">
        <a name="M001663"></a>

        <div class="method-heading">
          <a href="#M001663" class="method-signature">
          <span class="method-name">instantiator?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001663-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001663-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/dynamic_finder_match.rb, line 33</span>
33:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">instantiator?</span>
34:       <span class="ruby-ivar">@finder</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:first</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@instantiator</span>.<span class="ruby-identifier">nil?</span>
35:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>